package com.yebxxx.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yebxxx.server.mapper.EmployeeMapper;
import com.yebxxx.server.pojo.CountGender;
import com.yebxxx.server.pojo.CountDegree;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/countGender")
public class CountController {
    @Autowired
    private EmployeeMapper employeeMapper;
    @GetMapping("/")
    @ApiOperation(value = "统计男女人数")
    public CountGender CountGender(){
        CountGender countGender=new CountGender();
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("gender","男");
        queryWrapper.select("id");
        Integer countM = employeeMapper.selectCount(queryWrapper);
        countGender.setCountMan(countM);

        QueryWrapper queryWrappers=new QueryWrapper();
        queryWrappers.eq("gender","女");
        queryWrappers.select("id");
        Integer countWo = employeeMapper.selectCount(queryWrappers);
        countGender.setCountWoman(countWo);

        return  countGender;
    }
    @GetMapping("/degree")
    @ApiOperation(value = "统计学历分配状况")
    public CountDegree CountDegree(){
        CountDegree countDegree=new CountDegree();
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("tiptopDegree","博士");
        queryWrapper.select("id");
        Integer a = employeeMapper.selectCount(queryWrapper);
        countDegree.setBoshi(a);

//      countDegree.setShuoshi(employeeMapper.selectCount(new QueryWrapper<>().eq("tiptopDegree","硕士"));
        QueryWrapper queryWrapper1=new QueryWrapper();
        queryWrapper1.eq("tiptopDegree","硕士");
        queryWrapper1.select("id");
        Integer b = employeeMapper.selectCount(queryWrapper1);
        countDegree.setShuoshi(b);

        QueryWrapper queryWrapper2=new QueryWrapper();
        queryWrapper2.eq("tiptopDegree","本科");
        queryWrapper2.select("id");
        Integer c = employeeMapper.selectCount(queryWrapper2);
        countDegree.setBenke(c);

        QueryWrapper queryWrapper3=new QueryWrapper();
        queryWrapper3.eq("tiptopDegree","大专");
        queryWrapper3.select("id");
        Integer d = employeeMapper.selectCount(queryWrapper3);
        countDegree.setDazhuan(d);

        QueryWrapper queryWrapper4=new QueryWrapper();
        queryWrapper4.eq("tiptopDegree","高中");
        queryWrapper4.select("id");
        Integer e  = employeeMapper.selectCount(queryWrapper4);
        countDegree.setGaozhong(e);

        QueryWrapper queryWrapper5=new QueryWrapper();
        queryWrapper5.eq("tiptopDegree","初中");
        queryWrapper5.select("id");
        Integer f  = employeeMapper.selectCount(queryWrapper5);
        countDegree.setChuzhong(f);
//
//        QueryWrapper queryWrapper6=new QueryWrapper();
//        queryWrapper6.eq("tiptopDegree","高中");
//        queryWrapper6.select("id");
//        Integer g  = employeeMapper.selectCount(queryWrapper);
//        countDegree.setXiaoxue(g);

        QueryWrapper queryWrapper7=new QueryWrapper();
        queryWrapper7.eq("tiptopDegree","小学");
        queryWrapper7.select("id");
        Integer h  = employeeMapper.selectCount(queryWrapper7);
        countDegree.setXiaoxue(h);

        QueryWrapper queryWrapper8=new QueryWrapper();
        queryWrapper8.eq("tiptopDegree","其他");
        queryWrapper8.select("id");
        Integer i  = employeeMapper.selectCount(queryWrapper8);
        countDegree.setQita(i);

        return  countDegree;
    }

}
